// import * as api from '@/services/api.js';
import {productConfig} from '@/services/api/maintain';

const initState = () => {
  return {
    polyTransfer: false,
    loginIsFocus: false,
    maintainConfig:undefined,
  };
};

const getters = {};

// actions
const actions = {
  [types.POLY_TRANSFER]({state, commit}, flag = true) {
    commit(types.POLY_TRANSFER, flag);
    return new Promise((resolve) => {
      _.delay(() => {
        resolve(true);
      }, 1000);
    });
  },
    // 获取维护配置信息
    async [types.GET_MAINTAIN_CONFIG]({commit}, {type}) {
        const [result, data] = await productConfig({type});
        if (result !== false) {
            commit(types.GET_MAINTAIN_CONFIG, data);
        }
        return {result, data};
    }
};

// mutations
const mutations = {
  [types.POLY_TRANSFER](state, flag = true) {
    state.polyTransfer = flag;
  },
    [types.GET_MAINTAIN_CONFIG](state,data) {
        state.maintainConfig = data;
    },
};

export default {
  state: initState,
  getters,
  actions,
  mutations,
};
